import { makeAutoObservable } from 'mobx';
import { classRank, getInfo,selectClassPlan,selectClassPlanInit,} from '@/services/index';
import {IuserInfo,ISelectData,IGroupData,IClassRanklist} from '@/utils/trainingInterface'

class Training{
  constructor() {
    makeAutoObservable(this)
  }
  user: IuserInfo = {} as IuserInfo;
  selectData: ISelectData[] = [];
  groupData: IGroupData = {} as IGroupData;
  classRanklist:IClassRanklist[] = [];
  
  async getinfo() {
    //此getinfo为class类的方法,在类里调用需要加this
    let res = await getInfo();//此getinfo为引入接口
    if (res.data) {
      this.user=res.user
    }
    return res.user
  }
  async selectClassPlan() {
    let res = await selectClassPlan();
    // console.log(res.data);
    if (res.data) {
      this.selectData=res.data
    }
  }
  async selectClassPlanInit(classid:string,id:string) {
    let res = await selectClassPlanInit(classid,id);
    console.log(res);
    if (res.data) {
      this.groupData=res.data
    }
  }
  async classRank(id:string) {
    let res = await classRank(id);
    console.log(res.data);
    if (res.data) {
      this.classRanklist=res.data
    }
  }

}
export default new Training;